package cn.qqy.base.listener;


import cn.qqy.base.service.IAutoScanPermissionService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener  //把当前的类交给springIOC容器
public class InitPermissionListener implements ServletContextListener {

    @Autowired
    private IAutoScanPermissionService autoScanPermissionService;

    @Override
    public void contextInitialized(ServletContextEvent sce) {//容器初始化

        System.out.println("-----------初始化-------------");
        autoScanPermissionService.scan();
        System.out.println("-----------初始化结束-------------");

    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {//销毁
        System.out.println("-----------销毁-------------");

    }
}
